﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Compare lexicographically</title>
    <link href="styles/js-console.css" rel="stylesheet" />
</head>
<body>
    <div id="js-console"></div>
	<script src="scripts/js-console.js"></script>
	<script>
	    var arr1 = ["hello"];
	    var arr1Length = arr1.length;
	    var arr2 = ["abcde"];
	    var arr2Length = arr2.length;
	    var equal = true;
	    if(arr1Length != arr2Length) {
	        equal = false;
	        if(arr1Length<arr2Length){
	            jsConsole.writeLine("The first array is lexicographically first");
	        }
	        else{
	            jsConsole.writeLine("The second array is lexicographically first");
	        }
	    }
	    else{
	        for (var i = 0; i < arr1Length; i++){
                if(arr1[i] == arr2[i]){
                continue;
	            }
	            else{
                    equal = false;
	                if (arr1[i] > arr2[i]){
	                jsConsole.writeLine("The second array is lexicographically first");
	                 }
	                 else{
	                jsConsole.writeLine("The first array is lexicographically first");
	                }
	            }
	         }
	    }
	    if (equal == true){
	        jsConsole.writeLine("The two arrays are equal lexicographically");
	    }
    </script>
</body>
</html>
